<?php
@header('Content-type: text/html;charset=UTF-8');
require_once('bookmark_sum.php');
session_start();
if (isset($_SESSION['valid_user'])) {
$user_info=$_SESSION['valid_user'];
do_html_header();
do_html_introduce();
do_html_menu($user_info);
do_html_add_content();
if (isset($_POST['url_name'])&&isset($_POST['url'])) {
	try{
		check_url($_POST['url']);
		$url_name=$_POST['url_name'];
		$url=$_POST['url'];
		$conn=db_connect();
		echo "$user_info";
		$query_result=$conn->query("insert into bookmark values('".$user_info."','".$url."','".$url_name."')");
		if ($query_result) {
			echo '<p>添加成功，<a href="./add_mark.php">再次添加！</a></p>';
		}
		else{
			echo '<p>添加失败，<a href="./add_mark.php">重新添加！</a></p>';
		}
	}
	catch(Exception $e)
	{
		echo $e->getMessage();
	}
}
}
else{
	printf('<script type="text/javascript">location.href="login.php";</script>');
}
?>